<?php
App::import('Model', 'news.Article');
class TestsController extends AppController{
	var $name = 'Tests';
	var $helpers = array('Html', 'Form');
	var $uses = array('Article','Section','User');

	function get_records($modelClass) {
		//debug($this->{$modelClass}->_schema);exit;
		$records = $this->{$modelClass}->findAll(null,null);
		
    	$data = array();
		foreach ($records as $record) {
			$tmp = array();
			foreach ($this->{$modelClass}->_schema as $field => $info) {
				$tmp[] = "'".$field."' => '".$record[$modelClass][$field]."'";
			}
			$data[] = "array (".implode(', ',$tmp).")";
		}
		echo "<pre>";
		echo "var $records = array( <br/>";
		echo implode(',<br/>',$data);
		echo "); ";
		exit;
	}
	function testAddArticle() {
		$title = "Test title";
		$alias = "test_article";
		$description = "xin chao cac ban";
		$image = "image.png";
		$setion_id = 6;
		$content = "Test content";
		$section_tag_ids=array(1,3,5,7);
		$status = 0;
		$article_id = $this->Article->addArticle($title, $alias, $description, $image, $setion_id, $content, $section_tag_ids, $status );
		$info = $this->Article->read(null, $article_id);
		debug($info);exit;
	}
}
?>